<template>
    <div>
<h3>排房添加</h3>
<table class="table table-bordered">
            <tbody>
                <tr>
                    <td>门店</td>
                    <td><select v-model="a.ShopId">
                            <option value="">请选择</option>
                            <option :value="item.Id" v-for="item in data.shopList">{{ item.ShopName }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>房型名称</td>
                    <td><select v-model="a.HouseTypeId" @change="gethousenumberlist">
                            <option value="">请选择</option>
                            <option :value="item.Id" v-for="item in data.housetypeList">{{ item.HouseTypeName }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>房号名称</td>
                    <td><select v-model="a.HouseNumberId">
                            <option value="">请选择</option>
                            <option :value="item.Id" v-for="item in data.housenumberlist">{{ item.HouseName }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>姓名</td>
                    <td><input type="text" v-model="a.HouseRowName"></td>
                </tr>
                <tr>
                    <td>手机号</td>
                    <td><input type="text" v-model="a.Phone"></td>
                </tr>
                <tr>
                    <td>身份证</td>
                    <td><input type="text" v-model="a.Card"></td>
                </tr>
                <tr>
                    <td>入住时间</td>
                    <td><input type="date" v-model="a.BeginTime"></td>
                </tr>
                <tr>
                    <td>离店时间</td>
                    <td><input type="date" v-model="a.EndTime"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="增加" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import axios from 'axios';
import moment from 'moment';
const router = useRouter();
const route = useRoute();

onMounted(() => {
    getshoplist();
    gettypelist();
})

let a:any=reactive({
ShopId:'',
HouseTypeId:'',
HouseNumberId:'',
HouseRowName:'',
Phone:'',
Card:'',
BeginTime:'',
EndTime:''

})

let data: any = reactive({
    shopList: [],
    housetypeList: [],
    housenumberlist:[]
})

const ok:any=()=>{
    axios({
        url:'/api/HouseRow/Add',
        method:'post',
        data:a
    })
    .then((res)=>{
        if(res.data>0)
        {
            alert("成功");
            router.push("/houserowlist")
        }
    })
}

const gethousenumberlist=()=>{
    axios({
        url: '/api/HouseNumber/GetHouseNoList',
        method: 'get',
        params: {
            pageHang:100,
            housetypeId:a.HouseTypeId,
            shopId:a.ShopId
        }
    })
        .then((res) => {
            console.log(res);
           data.housenumberlist=res.data.list
        })

}

const getshoplist = () => {
    axios({
        method: 'get',
        url: '/api/Shop/GetShopList',
        params: {
            pageSize: 99,
            pageIndex: 1
        }
    })
        .then((res) => {
            console.log(res)
            data.shopList = res.data.list;


        })
        .catch((err) => {
            console.log(err);
        })
}

const gettypelist = () => {
    axios({
        url: 'api/HouseType/ShowHouse',
        method: 'get',
        params: {
            pageYe: 1,
            pageHang: 99
        }
    })
        .then((res) => {
            console.log(res);
            data.housetypeList = res.data.list;
        })
}



</script>

<style scoped>

</style>